import { type App } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

import layout from '@/layout/index.vue'
import login from '@/views/login/index.vue'
import demo from '@/views/demo/storeManagement/index.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'login',
    component: login,
  },
  {
    path: '/layout',
    name: 'layout',
    component: layout,
    children: [
      {
        path: '/store',
        name: 'store',
        component: demo,
      },
    ],
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

const initRouter = (app: App<Element>) => {
  app.use(router)
}

export { initRouter }

// export default router
